var express = require('express');
var path = require('path');
var cookieParser = require('cookie-parser');
var logger = require('morgan');

var indexRouter = require('./routes/index');
var usersRouter = require('./routes/users');//yyf
var clientRouter = require('./routes/client');//wcc
var roomRouter = require('./routes/room')//zzq
var reserveRouter = require('./routes/reserve')//wj
var payRouter = require('./routes/pay')//ckz
var financeRouter = require('./routes/finance')//xzx

var app = express();

app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));

app.all('*', function(req, res, next) {
    res.header("Access-Control-Allow-Origin", "*");
    res.header("Access-Control-Allow-Headers", "*");
    res.header("Access-Control-Allow-Methods","PUT,POST,GET,DELETE,OPTIONS");
    // res.header("X-Powered-By",' 3.2.1')
    // res.header("Content-Type", "application/json;charset=utf-8");
    next();
  });

app.get("/test",function(request,response){
    response.send("测试成功");
    //响应数据到客户端
})
app.use('/', indexRouter);
app.use('/users', usersRouter);
app.use('/client', clientRouter);
app.use('/room',roomRouter);
app.use('/reserve',reserveRouter);
app.use('/pay',payRouter);
app.use('/finance',financeRouter);

module.exports = app;
